package com.qf.cloud2202.microc.controller;

import com.qf.cloud2202.microc.feign.MicroAClient;
import com.qf.cloud2202.vo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/c")
public class TestController {

    @Autowired
    MicroAClient microAClient;


    @GetMapping("/test1")
    public String test1(){

        System.out.println("进入服务C的test1方法");

        // 调用微服务A 的接口
        final String s = microAClient.test1();

        return "微服务C收到了来自A的接口数据:"+s;

    }

    @GetMapping("/test2")
    public List<User> test2(){

        System.out.println("进入服务C的test2方法");

        final List<User> all = microAClient.getAll();

        return all;

    }

    @GetMapping("/test3")
    public User test3(){

        System.out.println("进入服务C的test3方法");

        final User zero = new User(500, "zero");

        final User update = microAClient.update(zero);

        return update;

    }

    @GetMapping("/test4")
    public User test4(){

        System.out.println("进入服务C的test4方法");

        final User delete = microAClient.delete(100);

        return delete;

    }



}
